package com.enjoyor.soa.traffic.frame.configure;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.enjoyor.soa.traffic.frame.properties.FileHanderProperties;

@Configuration
@EnableConfigurationProperties({ FileHanderProperties.class })
@ComponentScan(basePackages = { "com.enjoyor.soa.traffic.frame.support.file" })
public class FileHandleConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private FileHanderProperties fileHanderProperties;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(fileHanderProperties.getResource())
                .addResourceLocations("file:" + fileHanderProperties.getFileDir()+"//");
        super.addResourceHandlers(registry);
    }

}
